(function() {
    //获取元素节点
    var leftbtn = document.getElementById('show-left-btn');
    var rightbtn = document.getElementById('show-right-btn');
    var show = document.getElementById('show-ul');

    //序号
    var idx = 0;
    //节流锁
    var lock = true;

    //右按钮监听事件
    rightbtn.addEventListener('click',function() {
        if(!lock) return;

        lock = false;

        idx++;
        if(idx > 5) {
            show.style.left = 221 * -5 + 'px';
            idx = 5;
        }else {
            show.style.left = 221 * -idx + 'px';
        }
        setTimeout(() => {
            lock = true;
        }, 300);
    },false)
    //左按钮点击事件
    leftbtn.addEventListener('click',function() {
        if(!lock) return;

        lock = false;

        idx--;
        if(idx < 0) {
            show.style.left = 221 * 0 + 'px';
            idx = 0;
        }else {
            show.style.left = 221 * -idx + 'px';
        }

        setTimeout(() => {
            lock = true;
        }, 300);
    },false)
})()